package com.wfw.frist.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.wfw.common.pojo.TestVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

/**
 * @ Author     ：duanchao
 * @ Date       ： 9:39 2021/1/4
 * @ Description：
 */

@RestController
@RequestMapping("frist")
public class FristController {



    @RequestMapping("/uuid")
    @SentinelResource(value = "uu")
    public String fristTest(){
        System.out.println("uuuuuuuuuuuuuuu");
        return UUID.randomUUID().toString();
    }

    /**get 单参*/
    @GetMapping(value = "/firstParamo")
    String firstParam( String uname){
        System.out.println("firstParamo:"+uname);
        return "firstParamo:"+uname;
    }
    /**get 多参*/
    @GetMapping(value = "/secondParam")
    TestVo secondParam(  String uname,  Integer age){
        System.out.println("secondParam:"+uname+":"+age);
        TestVo testVo = new TestVo();
        testVo.setUname(uname);
        testVo.setAge(age+1);

        return testVo;
    }

    /**get 对象*/
    @GetMapping("/test/pojo")
    public  String testGetPojo( TestVo testVo){
        System.out.println(testVo);
        if(null!=testVo ||StringUtils.isNotBlank(testVo.getUname())||null!=testVo.getAge()){
            return  "数据不为空";
        }else {
            return "数据为空";
        }

    }

    @GetMapping(value = "/requestBodyGet")
    String requestBodyGet (@RequestBody  TestVo testVo){
        System.out.println("requestBodyGet:"+testVo);
        return "requestBodyGet";
    }


    @PostMapping(value = "/postFirstParam")
    String postFirstParam( @RequestBody String uname){
        System.out.println("postFirstParam:"+uname);
        return "postFirstParam:"+uname;
    }

    @PostMapping(value = "/postSecondParam")
    String postSecondParam(String uname, @RequestBody Integer age){
        System.out.println("postSecondParam:"+uname+":"+age);
        return "postSecondParam:"+uname+":"+age;
    }

    @PostMapping(value = "/postTestGetPojo")
    String postTestGetPojo(@RequestBody TestVo testVo){
        System.out.println("postTestGetPojo:"+testVo);
        return "postTestGetPojo";
    }


}